/// 适配协议：http、grpc。。。
pub fn save_user(request: SaveUserRequest) -> Result<(), String> {
    let dto = crate::port::UserDTO {
        id: request.id.clone(),
        name: request.name.clone(),
        email: request.email.clone(),
        street: request.street.clone(),
        city: request.city.clone(),
        state: request.state.clone(),
    };
    let user_port = crate::port::UserPort::new(Box::new(UserRepositoryImpl {}));
    user_port.update_user(dto)
}

pub struct SaveUserRequest {
    pub id: String,
    pub name: String,
    pub email: String,
    pub street: String,
    pub city: String,
    pub state: String,
}

pub struct UserRepositoryImpl {}
impl crate::domain::user::repository::UserRepository for UserRepositoryImpl {
    fn find_by_id(&self, id: String) -> Option<crate::domain::user::entity::User> {
        println!("User found {}", id);
        Some(crate::domain::user::entity::User {
            id: "1".to_string(),
            name: "John Doe".to_string(),
            email: "".to_string(),
            address: crate::domain::user::vo::Address {
                street: "123 Main St".to_string(),
                city: "Springfield".to_string(),
                state: "IL".to_string(),
            },
        })
    }
    fn save(&self, user: crate::domain::user::entity::User) -> Result<(), String> {
        println!("User saved: {:?}", user);
        Ok(())
    }
}
